<?php
require_once("conf/db_connection.php");
$id = $_GET['id'];
$new_stat = "";

$query_stat = "SELECT status FROM trip_detail WHERE id='".$id."'";
$result_stat = mysql_query($query_stat) or die("SELECT STATUS ");
$row_stat = mysql_fetch_array($result_stat);
$old_stat = $row_stat['status'];

switch ($old_stat) {
    case "awarded":
        $new_stat = "pullout";
        break;
    case "pullout":
        $new_stat = "pickup";
        break;
    case "pickup":
        $new_stat = "inyard";
        break;
	case "inyard":
        $new_stat = "complete";
        break;
}

$query_up = "UPDATE trip_detail SET status='".$new_stat."' WHERE id='".$id."'";
mysql_query($query_up) or die("UPDATE STATUS ".mysql_error());

$query_insert = "INSERT INTO status_log (trip_detail_id, status,updated_by) VALUES
('".$id."','".$new_stat."','".$_SESSION["username_nn"]."')";
mysql_query($query_insert) or die("INSERT STATUS LOG".mysql_error());

echo "1";
?>